﻿Imports System.IO
Imports System.Xml
Imports ModifyOutlook


Module OutlookContactCreate

    Sub Main()
        'Load the xml user control file
        Try
            Dim m_xmld As XmlDocument
            Dim m_nodelist As XmlNodeList
            Dim m_node As XmlNode
            Dim o As New ModifyOutlook.ModifyOutLook

            'Create the XML Document
            m_xmld = New XmlDocument()
            'Load the Xml file
            m_xmld.Load("contact_control.xml")
            'Get the list of name nodes 
            m_nodelist = m_xmld.SelectNodes("/user_control/folder_info")
            'First we have to delete all previous appointments

            'Loop through the nodes
            For Each m_node In m_nodelist
                Dim folder = m_node.Item("folder").InnerXml
                Dim username = m_node.Item("username").InnerXml
                Dim pwd = m_node.Item("pwd").InnerXml
                Dim domain = m_node.Item("domain").InnerXml
                Dim server = m_node.Item("server").InnerXml
                Dim contact_file = m_node.Item("contact_file").InnerXml
                
                o.folder = folder
                o.username = username
                o.pwd = pwd
                o.domain = domain
                o.contact_file = contact_file
                o.server = server

               
                Console.WriteLine("Deleting Outlook Contact....")
                o.FindAndDeleteOutlookContactsEWS()

                Console.WriteLine("Call BuildOutlookContact: " & folder)
                o.BuildOutlookContactEWS()


            Next
        Catch errorVariable As Exception
            'Error trapping
            Console.Write(errorVariable.ToString())
        End Try

    End Sub

End Module






